Skip to content

Conversation

@mehmet-yoti
Copy link
Contributor

Static Liveness Check Implementation

Overview

This implementation adds support for Static Liveness Check to the Yoti Python SDK, enabling identity verification using a single static image instead of the ZOOM liveness method which requires multiple frames and facemap data.

Features Added

1. Session Creation (Request Side)

Create STATIC Liveness Check

from yoti_python_sdk.doc_scan import RequestedLivenessCheckBuilder

# Build a STATIC liveness check
liveness_check = (
    RequestedLivenessCheckBuilder()
    .for_static_liveness()
    .with_max_retries(3)
    .with_manual_check_never()
    .build()
)

Generated JSON:

{
  "type": "LIVENESS",
  "config": {
    "liveness_type": "STATIC",
    "manual_check": "NEVER",
    "max_retries": 3
  }
}

2. Session Retrieval (Response Side)

Access STATIC Liveness Resources

from yoti_python_sdk.doc_scan import DocScanClient

client = DocScanClient(sdk_id, key_file_path)
session_result = client.get_session(session_id)

# Get all STATIC liveness resources
static_resources = session_result.resources.static_liveness_resources

for resource in static_resources:
    print(f"Resource ID: {resource.id}")
    print(f"Liveness Type: {resource.liveness_type}")
    
    # Access the image and media
    if resource.image and resource.image.media:
        media_id = resource.image.media.id
        media_type = resource.image.media.type
        created = resource.image.media.created
        
        print(f"Media ID: {media_id}")
        print(f"Media Type: {media_type}")

3. Media Content Retrieval

Download STATIC Liveness Image

# Get the first STATIC liveness resource
static_liveness = session_result.resources.static_liveness_resources[0]

# Extract media ID
media_id = static_liveness.image.media.id

# Retrieve the actual image content
media_content = client.get_media_content(session_id, media_id)

# Access the image bytes and MIME type
image_bytes = media_content.content
mime_type = media_content.mime_type  # e.g., "image/jpeg" or "image/png"

# Save to file
with open(f"liveness_image.{mime_type.split('/')[-1]}", "wb") as f:
    f.write(image_bytes)

Run Tests

# Run STATIC liveness tests only
pytest yoti_python_sdk/tests/doc_scan/session/create/check/test_liveness_check.py -v
pytest yoti_python_sdk/tests/doc_scan/session/retrieve/test_static_liveness_resource.py -v

# Run all doc_scan tests
pytest yoti_python_sdk/tests/doc_scan/ -v

Example Application

The Flask example application (examples/doc_scan/) now displays Static Liveness resources on the success page:

  • Shows resource ID and liveness type
  • Displays the static liveness image
  • Provides media ID for reference
  • Uses collapsible accordion UI similar to ZOOM liveness

Backward Compatibility

Fully backward compatible - All existing code using ZOOM liveness continues to work without any changes:

# Existing ZOOM liveness code still works
zoom_check = RequestedLivenessCheckBuilder().for_zoom_liveness().build()
zoom_resources = session_result.resources.zoom_liveness_resources

# New STATIC liveness code
static_check = RequestedLivenessCheckBuilder().for_static_liveness().build()
static_resources = session_result.resources.static_liveness_resources

Acceptance Criteria

All three acceptance criteria have been met:

  1. Add support for requesting a liveness check type STATIC

    • Implemented via for_static_liveness() builder method
    • Supports manual_check parameter (defaults to "NEVER")
  2. Add support for retrieving the updated liveness check response

    • Created StaticLivenessResourceResponse class
    • Added static_liveness_resources filter property
    • Parses image and media objects correctly
  3. Ensure that the SDKs support retrieving the media for the STATIC liveness check

    • Media ID accessible via resource.image.media.id
    • Existing get_media_content() method works seamlessly
    • Example application displays the image

For Existing Implementations

No changes required! Your existing ZOOM liveness code will continue to work. You can optionally add STATIC liveness support:

# Add STATIC liveness alongside existing ZOOM liveness
session_spec = (
    SessionSpecBuilder()
    .with_requested_check(
        RequestedLivenessCheckBuilder()
        .for_zoom_liveness()  # Existing
        .with_max_retries(1)
        .build()
    )
    .with_requested_check(
        RequestedLivenessCheckBuilder()
        .for_static_liveness()  # New
        .with_max_retries(3)
        .with_manual_check_never()
        .build()
    )
    # ... other configuration
    .build()
)

davidgrayston and others added 30 commits November 16, 2020 16:21
Merge master 1.14.0 → development
NA: Update dependabot reviewers
SDK-1583: Merge GitHub actions CI steps into development
Bumps [protobuf](https://github.com/protocolbuffers/protobuf) from 3.17.1 to 3.17.3.
- [Release notes](https://github.com/protocolbuffers/protobuf/releases)
- [Changelog](https://github.com/protocolbuffers/protobuf/blob/master/generate_changelog.py)
- [Commits](protocolbuffers/protobuf@v3.17.1...v3.17.3)

---
updated-dependencies:
- dependency-name: protobuf
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
# Conflicts:
#	examples/yoti_example_django/requirements.txt
Bumps [virtualenv](https://github.com/pypa/virtualenv) from 20.4.7 to 20.7.2.
- [Release notes](https://github.com/pypa/virtualenv/releases)
- [Changelog](https://github.com/pypa/virtualenv/blob/main/docs/changelog.rst)
- [Commits](pypa/virtualenv@20.4.7...20.7.2)

---
updated-dependencies:
- dependency-name: virtualenv
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [cffi](http://cffi.readthedocs.org) from 1.14.5 to 1.14.6.

---
updated-dependencies:
- dependency-name: cffi
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [iso8601](https://github.com/micktwomey/pyiso8601) from 0.1.14 to 0.1.16.
- [Release notes](https://github.com/micktwomey/pyiso8601/releases)
- [Commits](micktwomey/pyiso8601@0.1.14...0.1.16)

---
updated-dependencies:
- dependency-name: iso8601
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [virtualenv](https://github.com/pypa/virtualenv) from 20.7.2 to 20.8.1.
- [Release notes](https://github.com/pypa/virtualenv/releases)
- [Changelog](https://github.com/pypa/virtualenv/blob/main/docs/changelog.rst)
- [Commits](pypa/virtualenv@20.7.2...20.8.1)

---
updated-dependencies:
- dependency-name: virtualenv
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [deprecated](https://github.com/tantale/deprecated) from 1.2.12 to 1.2.13.
- [Release notes](https://github.com/tantale/deprecated/releases)
- [Changelog](https://github.com/tantale/deprecated/blob/master/CHANGELOG.rst)
- [Commits](laurent-laporte-pro/deprecated@v1.2.12...v1.2.13)

---
updated-dependencies:
- dependency-name: deprecated
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
echarrod and others added 30 commits January 12, 2022 13:28
SDK-2027: adding non-latin support for session and supported documents
SDK-1901: Adding WATCHLIST_SCREENING check
SDK-1838 auth_type for doc_scan session
Bumps [pytz](https://github.com/stub42/pytz) from 2021.1 to 2021.3.
- [Release notes](https://github.com/stub42/pytz/releases)
- [Commits](stub42/pytz@release_2021.1...release_2021.3)

---
updated-dependencies:
- dependency-name: pytz
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [virtualenv](https://github.com/pypa/virtualenv) from 20.12.0 to 20.13.0.
- [Release notes](https://github.com/pypa/virtualenv/releases)
- [Changelog](https://github.com/pypa/virtualenv/blob/main/docs/changelog.rst)
- [Commits](pypa/virtualenv@20.12.0...20.13.0)

---
updated-dependencies:
- dependency-name: virtualenv
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [protobuf](https://github.com/protocolbuffers/protobuf) from 3.19.3 to 3.19.4.
- [Release notes](https://github.com/protocolbuffers/protobuf/releases)
- [Changelog](https://github.com/protocolbuffers/protobuf/blob/master/generate_changelog.py)
- [Commits](protocolbuffers/protobuf@v3.19.3...v3.19.4)

---
updated-dependencies:
- dependency-name: protobuf
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
# Conflicts:
#	.github/workflows/tests.yaml
#	.pre-commit-config.yaml
#	examples/yoti_example_flask/requirements.in
#	examples/yoti_example_flask/requirements.txt
#	requirements.in
#	requirements.txt
#	setup.py
#	sonar-project.properties
#	yoti_python_sdk/version.py
Bumps [pip-tools](https://github.com/jazzband/pip-tools) from 6.4.0 to 6.6.2.
- [Release notes](https://github.com/jazzband/pip-tools/releases)
- [Changelog](https://github.com/jazzband/pip-tools/blob/master/CHANGELOG.md)
- [Commits](jazzband/pip-tools@6.4.0...6.6.2)

---
updated-dependencies:
- dependency-name: pip-tools
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [virtualenv](https://github.com/pypa/virtualenv) from 20.13.0 to 20.14.1.
- [Release notes](https://github.com/pypa/virtualenv/releases)
- [Changelog](https://github.com/pypa/virtualenv/blob/main/docs/changelog.rst)
- [Commits](pypa/virtualenv@20.13.0...20.14.1)

---
updated-dependencies:
- dependency-name: virtualenv
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [werkzeug](https://github.com/pallets/werkzeug) from 2.0.2 to 2.1.2.
- [Release notes](https://github.com/pallets/werkzeug/releases)
- [Changelog](https://github.com/pallets/werkzeug/blob/main/CHANGES.rst)
- [Commits](pallets/werkzeug@2.0.2...2.1.2)

---
updated-dependencies:
- dependency-name: werkzeug
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [virtualenv](https://github.com/pypa/virtualenv) from 20.14.1 to 20.15.1.
- [Release notes](https://github.com/pypa/virtualenv/releases)
- [Changelog](https://github.com/pypa/virtualenv/blob/main/docs/changelog.rst)
- [Commits](pypa/virtualenv@20.14.1...20.15.1)

---
updated-dependencies:
- dependency-name: virtualenv
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
* added python static liveness check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants